function QuickIndex(){
	var appUrl;
	var image;
};

QuickIndex.prototype.ini = function(){
	this.appUrl='';
	this.image ='';
};

var __index = new QuickIndex();
__index.ini();

QuickIndex.prototype.checkTel = function(){
	var tel = $('#userTel').val();
	var action = "checktel";
	var telNum = tel.length;
	if(telNum==11){
		if(check_mobile(tel)){
			$.ajax({
					type: "POST",
					url:this.appUrl+'index.php',
					data:{tel:tel,ac:action},
					beforeSend:function(XMLHttpRequest){
						//Show Loading
						$('#test').html("<div><img src='style/images/loading.gif' class=\"juhua\" alt=''/></div>");
					},
					dataType:"json",
					success:function(data) {
						//alert(data);
						if(data.return_code==1){
							$('.showLogin').show();
							$('.buttonLogin').show();
							$('.showEmail').hide();
							$('.email').hide();
							$('.login').hide();
							$('.sendPwd').hide();
							$('.registerPwd').hide();
							$('.registerNewPwd').hide();
							$('.showRegisterPwd').hide();
							$('.showRegisterNewPwd').hide();
						}else if(data.return_code==0){
							$('.showLogin').hide();
							$('.login').hide();
							$('.registerPwd').hide();
							$('.registerNewPwd').hide();
							$('.buttonLogin').show();
							$('.sendPwd').show();
							$('.showRegisterPwd').show();
							$('.showRegisterNewPwd').show();
							$('.showEmail').show();
							$('.email').hide();
						}else{
							$('.showEmail').hide();
							$('.email').hide();
							$('.showLogin').hide();
							$('.login').hide();
							$('.buttonLogin').hide();
							$('.registerPwd').hide();
							$('.registerNewPwd').hide();
							$('.sendPwd').hide();
							$('.showRegisterPwd').hide();
							$('.showRegisterNewPwd').hide();
						}
					},
					complete: function(XMLHttpRequest, textStatus){
						//Hide Loading
						$('#test').html('');
						$('#login').attr("value","");
						$('#registerPwd').attr("value","");
						$('#registerNewPwd').attr("value","");
					},
					error:function(){alert('error');}
				});
		}else{
			//输入的不是11位号码
			//alert("请输入正确的手机号");
		}
	}
}

QuickIndex.prototype.clickInput = function(className){
	if(className=='registerPwd'){
		var password = $('#registerPwd').val();
		if(password==""){
			$('.registerPwd').hide();
			$('.showRegisterPwd').show();
		}
	}else if(className=='showRegisterPwd'){
		$('.showRegisterPwd').hide();
		$('.registerPwd').show();
		$('#registerPwd').focus();
	}else if(className=="showRegisterNewPwd"){
		$('.showRegisterNewPwd').hide();
		$('.registerNewPwd').show();
		$('#registerNewPwd').focus();
	}else if(className=='registerNewPwd'){
		var password = $('#registerNewPwd').val();
		if(password==""){
			$('.registerNewPwd').hide();
			$('.showRegisterNewPwd').show();
		}
	}else if(className=="showLogin"){
		$('.showLogin').hide();
		$('.login').show();
		$('#login').focus();
	}else if(className=="login"){
		var password = $('#login').val();
		if(password==""){
			$('.login').hide();
			$('.showLogin').show();
		}
	}else if(className=="email"){
		var email = $('#email').val();
		if(email==""){
			$('.email').hide();
			$('.showEmail').show();
		}
	}else if(className=="showEmail"){
		$('.showEmail').hide();
		$('.email').show();
		$('#email').focus();
		
	}
}

QuickIndex.prototype.leaveInput = function(className){
	if(className=='showRegisterPwd'){
		if($('#registerPwd').val()==""){
			$('.registerPwd').hide();
			$('.showRegisterPwd').show();
		}
	}else if(className=="showRegisterNewPwd"){
		if($('#registerNewPad').val()==""){
			$('.registerNewPwd').hide();
			$('.showRegisterNewPwd').show();
		}
	}else if(className=="showLogin"){
		if($('#login').val()==""){
			$('.login').hide();
			$('.showLogin').show();
		}
	}
}

QuickIndex.prototype.login = function(){
	var loginPwd = $('#login').val();
	var registerPwd = $('#registerPwd').val();
	var registerNewPwd = $('#registerNewPwd').val();
	var userTel = $('#userTel').val();
	var action = "loginCheck";
	if(loginPwd!=""){
		$.ajax({
			type: "POST",
			url:this.appUrl+'index.php',
			data:{userTel:userTel,loginPwd:loginPwd,action:action},
			dataType:"json",
			success:function(data){
				if(data.return_code==1){
					window.location.href="myinfo.php"; 
				}else if(data.return_code==0){
					alert("密码错误");
				}
			},
			error:function(){alert('error');}
		});
	}else if(registerPwd!="" && registerNewPwd!=""){
		$.ajax({
			type: "POST",
			url:this.appUrl+'index.php',
			data:{userTel:userTel,registerPwd:registerPwd,registerNewPwd:registerNewPwd,action:action},
			dataType:"json",
			success:function(data){
				if(data.return_code==1){
					window.location.href="myinfo.php"; 
				}else if(data.return_code==0){
					alert(data.desc);
				}
			},
			error:function(){alert('error');}
		});
	}else if(registerPwd!=""){
		$.ajax({
			type: "POST",
			url:this.appUrl+'index.php',
			data:{userTel:userTel,registerPwd:registerPwd,action:action},
			dataType:"json",
			success:function(data){
				if(data.return_code==1){
					window.location.href="myinfo.php"; 
				}else if(data.return_code==0){
					alert(data.desc);
				}
			},
			error:function(){alert('error');}
		});
	}
}

/**
 *发送验证码
 */
QuickIndex.prototype.sendPwd = function(){
	var userTel = $('#userTel').val();
	var action = "sendVerification";
	$.ajax({
		type:"post",
		url:this.appUrl+"index.php",
		data:{action:action,userTel:userTel},
		success:function(data){
			
		},
		error:function(){alert('error');}
	});
}
